﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using DTO;
using System.Data;

namespace BUS
{
    public class SachService
    {
        public static void ThemSach(SachDTO sachDTO)
        {
            try
            {
                SachRepository sachDAO = new SachRepository();
                sachDAO.ThemSach(sachDTO);
            }
            catch (System.Exception)
            {
            }
        }

        public static int LayMaSachMax()
        {
            int masach = 0;
            try
            {
                SachRepository sachDAO = new SachRepository();
                masach = sachDAO.LayMaSachMax();
            }
            catch (System.Exception)
            {
            }
            return masach;
        }

        public static SachDTO LayThongTinSach(int masach)
        {
            SachDTO sachDTO = new SachDTO();
            try
            {
                SachRepository sachRepo = new SachRepository();
                sachDTO = sachRepo.LayThongTinSach(masach);
            }
            catch (System.Exception)
            {
            }
            return sachDTO;
        }

        public static int LayMaSachTheoMaSoSach(string maso)
        {
            int masach = 0;
            try
            {
                SachRepository sachRepo = new SachRepository();
                masach = LayMaSachTheoMaSoSach(maso);
            }
            catch (System.Exception)
            {
            }
            return masach;
        }        

        public static DataTable TraCuuSach(string maSoSach, string tenSach, string tenTacGia, int maTheLoai, int maNXB, int namXB)
        {
            DataTable dbTraCuu = new DataTable();
            SachRepository sachRep = new SachRepository();
            dbTraCuu = sachRep.TraCuuSach(maSoSach, tenSach, tenTacGia, maTheLoai, maNXB, namXB);
            return dbTraCuu;
        }
        
        public static DataTable LayThongTinSachMat(int maSach)
        {
            DataTable sachMat = new DataTable();
            try
            {
                SachRepository sachRep = new SachRepository();
                sachMat = sachRep.LayThongTinSachMat(maSach);
            }
            catch(System.Exception)
            { }
            return sachMat;
        }
        public static void CapNhatSach(SachDTO sachDTO)
        {
            try
            {
                SachRepository sachRep = new SachRepository();
                sachRep.CapNhatSach(sachDTO);
            }
            catch (System.Exception)
            {

            }
        }
    }
}
